package user

import (
	"time"

	"go-api-template/api/http"
	"go-api-template/internal/util/cacheUtil"
	"go-api-template/service"
	"golang.org/x/sync/singleflight"

	"github.com/gin-gonic/gin"
)

// UserCache1 通过实现UserCache，自定义缓存
func (req *ListReq) UserCache1(key string, ctx *gin.Context, s *service.Service, sg *singleflight.Group) (resp http.Resp, err error) {
	resp, err = cacheUtil.RequestCache(key, 60*time.Second, s, sg, false, func() (http.Resp, error) {
		return req.Do(ctx, s)
	})
	return
}
